package com.oasystem.dao.jdbc.user;

import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;

import com.oasystem.domain.user.SystemMessage;

public class SystemMessageDao {
	
	private JdbcTemplate jdbcTemplate;
	
	public List<SystemMessage> findAll(int start,int limit) {
		String sql="SELECT * FROM systemmessage order by id desc LIMIT ?,?";
		return jdbcTemplate.queryForList(sql,new Object[]{start,limit}, SystemMessage.class);
	}

	public void insert( SystemMessage message) {
		String sql = "INSERT INTO systemmessage (context) VALUES (?)";
		jdbcTemplate.update(sql, new Object[]{message.getContext()});
	}

	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
		this.jdbcTemplate = jdbcTemplate;
	}
}
